home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / sbin / update-anthy-dics < prev    next >
Encoding:
Text File  |  2010-05-09  |  2.0 KB  |  96 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. CANNADIC='gcanna.ctd gcannaf.ctd gtankan.ctd'
  6. EXTRADIC='adjust.t compound.t extra.t'
  7. EXTRADIC_UTF8='g_fname.t'
  8.  
  9. DICDIR=/var/lib/anthy
  10. METADICDIR=/usr/share/anthy/dic
  11. DEPGRAPHDIR=/var/lib/anthy/depgraph
  12. WORDDICDIR=/var/lib/anthy/mkworddic
  13. CALCTRANSDIR=/var/lib/anthy/calctrans
  14.  
  15. CONFIG='/etc/anthy/diclist'
  16. DICTCONFIG='/etc/anthy/dict.args'
  17. TMPDICTCONFIG='/tmp/dict.args.XXXXXX'
  18.  
  19. OLDDIR=`pwd`
  20. cd $METADICDIR
  21.  
  22. TMPDICTCONFIG=$(mktemp $TMPDICTCONFIG)
  23. if [ $? != 0 ]; then
  24.     echo "mktemp failed, aborting" 1>&2
  25.     exit 1
  26. fi
  27.  
  28.  
  29. echo "set_input_encoding eucjp" >> $TMPDICTCONFIG
  30. for file in $CANNADIC $EXTRADIC
  31. do
  32.   if [ -f $file ]; then
  33.     echo "read $METADICDIR/$file" >> $TMPDICTCONFIG
  34.   fi
  35. done
  36.  
  37.  
  38. addondics=$(sort -u $CONFIG| tr '\n' ' '| sed 's/\ $//')
  39. for file in $addondics; do
  40.     if [ -f $file ]; then
  41.         echo "read $METADICDIR/$file" >> $TMPDICTCONFIG
  42.     fi
  43. done
  44.  
  45.  
  46. # start adding utf8 dict
  47. echo "set_input_encoding utf8" >> $TMPDICTCONFIG
  48. for utf_dict in $EXTRADIC_UTF8
  49. do
  50.   echo "read $METADICDIR/$utf_dict" >> $TMPDICTCONFIG
  51. done
  52. # end adding utf8 dict
  53.  
  54. echo "build_reverse_dict" >> $TMPDICTCONFIG
  55. echo "read_uc $METADICDIR/udict" >> $TMPDICTCONFIG
  56. echo "set_dict_encoding utf8" >> $TMPDICTCONFIG
  57. echo "write anthy.wdic" >> $TMPDICTCONFIG
  58. echo "done" >> $TMPDICTCONFIG
  59.  
  60. echo -n 'Updating anthy.dic...'
  61.  
  62. rm -rf $WORDDICDIR; mkdir $WORDDICDIR
  63. rm -rf $DEPGRAPHDIR; mkdir $DEPGRAPHDIR
  64. rm -f $CALCTRANSDIR
  65.  
  66. cp /etc/anthy/anthy-conf /var/lib/anthy
  67.  
  68. if [ -f $DICDIR/anthy.dic ]; then
  69.     rm -f $DICDIR/anthy.dic
  70. fi
  71.  
  72. mv $TMPDICTCONFIG $DICTCONFIG
  73.  
  74. cd $WORDDICDIR
  75. /usr/bin/mkworddic -f $DICTCONFIG > /dev/null 2>&1
  76.  
  77. cd $DEPGRAPHDIR
  78. for i in /usr/share/anthy/depgraph/*.depword; do
  79.     ln -s $i $DEPGRAPHDIR/`basename $i`
  80. done
  81. ln -sf /usr/share/anthy/depgraph/indepword.txt $DEPGRAPHDIR
  82.  
  83. ln -sf /usr/share/anthy/depgraph/conjugate.table $DEPGRAPHDIR
  84. /usr/bin/mkdepgraph 
  85.  
  86. ln -sf /usr/share/anthy/calctrans $CALCTRANSDIR
  87.  
  88. cd $DICDIR
  89. /usr/bin/mkfiledic -p ./
  90.  
  91. rm -f /var/lib/anthy/anthy-conf
  92.  
  93. cd $OLDDIR
  94.  
  95. echo 'done.'
  96.